############################################################################
#
# getCMImage - image extractor for cablemodems
# 2010,2011
#  
# Alejandro Alvarez
# ...
# 
# 
# Released under GPL
#
############################################################################

# convierte fichero
strings salida.txt > salida.strings.txt

# check errores
cat salida.strings.txt | grep Hz > /dev/null
if [ $? -ne 1 ]; then
        echo "=> Error fichero corrupto. $1 no se genera. (#SCAN-STOP)"
    exit 1
fi
cat salida.strings.txt | grep Lo > /dev/null
if [ $? -ne 1 ]; then
	echo "=> Error fichero corrupto. $1 no se genera. (#LOGING-EVENT)"
    exit 1
fi

# quitamos lineas sobrantes
cat salida.strings.txt | grep -v CG3100 | grep -v flash | grep -v Reading | grep -v Co | grep -vE "4 8192 (.*)" > temp.part

# quitamos espacios
sed 's/ //g' temp.part > $1

echo "=> Generado fichero $1 OK."
